package cn.edu.web;

import cn.edu.pojo.Brand;
import cn.edu.service.BrandService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Davey chan
 */
@WebServlet("/selectByIdServlet")
public class SelectByIdServlet extends HttpServlet {
    private BrandService brandService = new BrandService();
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        接受ID
        String id = request.getParameter("id");
//        得到对应的品牌类
        Brand brand = brandService.selectById(Integer.parseInt(id));
        //        存入request域中
        request.setAttribute("brand",brand);
        //        转发到update.jsp中
        request.getRequestDispatcher("/updateBrand.jsp").forward(request,response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }


}
